main_plot_3
# Save the plot
ggsave("Plots/figd5.png", plot = main_plot_3, width = 25, height = 20, units = "cm")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import data with main analyses
data <- read.dta("Results/analyses_final.dta")
# Make the plot
firststage_plot_secondid <- data %>%
filter(Polynomials < 5) %>%
filter(FE == "None")  %>%
filter(Outcome == "Turnout")  %>%
mutate(Polynomials = as.factor(Polynomials)) %>%
ggplot(aes(x = Instruments, y = fstat, fill = Polynomials)) +
geom_bar(stat = "identity", position = position_dodge(0.75), color = "gray30") +
theme_bw() +
scale_y_continuous(limits = c(0, 10), breaks = c(0, 2, 4, 6, 8, 10)) +
ylab("F-test") +
scale_fill_brewer(palette = "YlGnBu") +
theme_minimal() +
geom_hline(yintercept = 9, color = "red", linetype = "dashed", size = 1) +
facet_wrap(.~ Predictor)
firststage_plot_secondid
# Save the plot
ggsave("Plots/figd6.png", plot = firststage_plot_secondid, width = 20, height = 15, units = "cm")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import dataset with results
dinas_only <- read.dta13("Results/analyses_final_dinasonly.dta")
# Defining line breaks in the type of outcome
levels(dinas_only$outcome_type) <- gsub("\\n", "\n", levels(dinas_only$outcome_type))
# Fixing levels in outcome and outcome_type variables
dinas_only$Outcome[dinas_only$Outcome == "Summary\\nmeasures (PCA)"] <- "Summary measures (PCA)"
dinas_only$Outcome[dinas_only$Outcome == "Repr underpriviliged\\ngroups (PCA)"] <- "Repr underpriviliged groups (PCA)"
dinas_only$outcome_type[dinas_only$outcome_type == "Summary\\nmeasures"] <- "Summary\nmeasures"
dinas_only$outcome_type[dinas_only$outcome_type == "Descriptive\\nrepr of women"] <- "Descriptive\nrepr of women"
dinas_only$outcome_type[dinas_only$outcome_type == "Repr underpriviliged\\ngroups"] <- "Repr underpriviliged\ngroups"
dinas_only$outcome_type[dinas_only$outcome_type == "Other\\noutcomes"] <- "Other\noutcomes"
# Creating a variable to order the plot by
dinas_only$order_outcome <- 1
dinas_only$order_outcome[dinas_only$outcome_type == "Summary\nmeasures"] <- 0
dinas_only$order_outcome[dinas_only$outcome_type == "Other\noutcomes"] <- 2
# Draw the actual plot
main_plot_dinas_only <- dinas_only %>%
mutate(Outcome = fct_reorder(Outcome, pca)) %>%
mutate(outcome_type = fct_reorder(outcome_type, order_outcome)) %>%
ggplot(aes(Outcome, Effect, color = factor(pca), show.legend = FALSE)) +
geom_hline(aes(yintercept = 0), linetype = 2) +
coord_flip(ylim = c(-1, 1)) +
geom_linerange(aes(ymin = ci_lower, ymax = ci_upper), position = position_dodge(width = 0.75) ) +
geom_point(size = 1, position = position_dodge(width = 0.75) ) +
facet_grid(rows = vars(outcome_type),
scales = "free_y") +
theme_minimal(base_size = 9) +
theme(legend.position = "none",
panel.background = element_rect(fill = NA, color = "black")) +
scale_color_manual(values = c("black", "blue")) +
ylab(" ") +
xlab("")
main_plot_dinas_only
# Save the plot
ggsave("Plots/figd6.png", plot = main_plot_3, width = 25, height = 20, units = "cm")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import dataset with results
dinas_only <- read.dta13("Results/analyses_final_dinasonly.dta")
# Defining line breaks in the type of outcome
levels(dinas_only$outcome_type) <- gsub("\\n", "\n", levels(dinas_only$outcome_type))
# Fixing levels in outcome and outcome_type variables
dinas_only$Outcome[dinas_only$Outcome == "Summary\\nmeasures (PCA)"] <- "Summary measures (PCA)"
dinas_only$Outcome[dinas_only$Outcome == "Repr underpriviliged\\ngroups (PCA)"] <- "Repr underpriviliged groups (PCA)"
dinas_only$outcome_type[dinas_only$outcome_type == "Summary\\nmeasures"] <- "Summary\nmeasures"
dinas_only$outcome_type[dinas_only$outcome_type == "Descriptive\\nrepr of women"] <- "Descriptive\nrepr of women"
dinas_only$outcome_type[dinas_only$outcome_type == "Repr underpriviliged\\ngroups"] <- "Repr underpriviliged\ngroups"
dinas_only$outcome_type[dinas_only$outcome_type == "Other\\noutcomes"] <- "Other\noutcomes"
# Creating a variable to order the plot by
dinas_only$order_outcome <- 1
dinas_only$order_outcome[dinas_only$outcome_type == "Summary\nmeasures"] <- 0
dinas_only$order_outcome[dinas_only$outcome_type == "Other\noutcomes"] <- 2
# Draw the actual plot
main_plot_dinas_only <- dinas_only %>%
mutate(Outcome = fct_reorder(Outcome, pca)) %>%
mutate(outcome_type = fct_reorder(outcome_type, order_outcome)) %>%
ggplot(aes(Outcome, Effect, color = factor(pca), show.legend = FALSE)) +
geom_hline(aes(yintercept = 0), linetype = 2) +
coord_flip(ylim = c(-1, 1)) +
geom_linerange(aes(ymin = ci_lower, ymax = ci_upper), position = position_dodge(width = 0.75) ) +
geom_point(size = 1, position = position_dodge(width = 0.75) ) +
facet_grid(rows = vars(outcome_type),
scales = "free_y") +
theme_minimal(base_size = 9) +
theme(legend.position = "none",
panel.background = element_rect(fill = NA, color = "black")) +
scale_color_manual(values = c("black", "blue")) +
ylab(" ") +
xlab("")
main_plot_dinas_only
# Save the plot
ggsave("Plots/figd6.png", plot = main_plot_dinas_only, width = 25, height = 20, units = "cm")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import dataset with results
dinas_only <- read.dta13("Results/analyses_final_dinasonly.dta")
# Defining line breaks in the type of outcome
levels(dinas_only$outcome_type) <- gsub("\\n", "\n", levels(dinas_only$outcome_type))
# Fixing levels in outcome and outcome_type variables
dinas_only$Outcome[dinas_only$Outcome == "Summary\\nmeasures (PCA)"] <- "Summary measures (PCA)"
dinas_only$Outcome[dinas_only$Outcome == "Repr underpriviliged\\ngroups (PCA)"] <- "Repr underpriviliged groups (PCA)"
dinas_only$outcome_type[dinas_only$outcome_type == "Summary\\nmeasures"] <- "Summary\nmeasures"
dinas_only$outcome_type[dinas_only$outcome_type == "Descriptive\\nrepr of women"] <- "Descriptive\nrepr of women"
dinas_only$outcome_type[dinas_only$outcome_type == "Repr underpriviliged\\ngroups"] <- "Repr underpriviliged\ngroups"
dinas_only$outcome_type[dinas_only$outcome_type == "Other\\noutcomes"] <- "Other\noutcomes"
# Creating a variable to order the plot by
dinas_only$order_outcome <- 1
dinas_only$order_outcome[dinas_only$outcome_type == "Summary\nmeasures"] <- 0
dinas_only$order_outcome[dinas_only$outcome_type == "Other\noutcomes"] <- 2
# Draw the actual plot
main_plot_dinas_only <- dinas_only %>%
mutate(Outcome = fct_reorder(Outcome, pca)) %>%
mutate(outcome_type = fct_reorder(outcome_type, order_outcome)) %>%
ggplot(aes(Outcome, Effect, color = factor(pca), show.legend = FALSE)) +
geom_hline(aes(yintercept = 0), linetype = 2) +
coord_flip(ylim = c(-1, 1)) +
geom_linerange(aes(ymin = ci_lower, ymax = ci_upper), position = position_dodge(width = 0.75) ) +
geom_point(size = 1, position = position_dodge(width = 0.75) ) +
facet_grid(rows = vars(outcome_type),
scales = "free_y") +
theme_minimal(base_size = 9) +
theme(legend.position = "none",
panel.background = element_rect(fill = NA, color = "black")) +
scale_color_manual(values = c("black", "blue")) +
ylab(" ") +
xlab("")
main_plot_dinas_only
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import dataset with results
dinas_only <- read.dta13("Results/analyses_final_dinasonly.dta")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import dataset with results
dinas_only <- read.dta13("Results/analyses_final_dinasonly.dta")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import dataset with results
dinas_only <- read.dta13("Results/analyses_final_dinasonly.dta")
# Defining line breaks in the type of outcome
levels(dinas_only$outcome_type) <- gsub("\\n", "\n", levels(dinas_only$outcome_type))
# Fixing levels in outcome and outcome_type variables
dinas_only$Outcome[dinas_only$Outcome == "Summary\\nmeasures (PCA)"] <- "Summary measures (PCA)"
dinas_only$Outcome[dinas_only$Outcome == "Repr underpriviliged\\ngroups (PCA)"] <- "Repr underpriviliged groups (PCA)"
dinas_only$outcome_type[dinas_only$outcome_type == "Summary\\nmeasures"] <- "Summary\nmeasures"
dinas_only$outcome_type[dinas_only$outcome_type == "Descriptive\\nrepr of women"] <- "Descriptive\nrepr of women"
dinas_only$outcome_type[dinas_only$outcome_type == "Repr underpriviliged\\ngroups"] <- "Repr underpriviliged\ngroups"
dinas_only$outcome_type[dinas_only$outcome_type == "Other\\noutcomes"] <- "Other\noutcomes"
# Creating a variable to order the plot by
dinas_only$order_outcome <- 1
dinas_only$order_outcome[dinas_only$outcome_type == "Summary\nmeasures"] <- 0
dinas_only$order_outcome[dinas_only$outcome_type == "Other\noutcomes"] <- 2
# Draw the actual plot
main_plot_dinas_only <- dinas_only %>%
mutate(Outcome = fct_reorder(Outcome, pca)) %>%
mutate(outcome_type = fct_reorder(outcome_type, order_outcome)) %>%
ggplot(aes(Outcome, Effect, color = factor(pca), show.legend = FALSE)) +
geom_hline(aes(yintercept = 0), linetype = 2) +
coord_flip(ylim = c(-1, 1)) +
geom_linerange(aes(ymin = ci_lower, ymax = ci_upper), position = position_dodge(width = 0.75) ) +
geom_point(size = 1, position = position_dodge(width = 0.75) ) +
facet_grid(rows = vars(outcome_type),
scales = "free_y") +
theme_minimal(base_size = 9) +
theme(legend.position = "none",
panel.background = element_rect(fill = NA, color = "black")) +
scale_color_manual(values = c("black", "blue")) +
ylab(" ") +
xlab("")
main_plot_dinas_only
# Save the plot
ggsave("Plots/figd6.png", plot = main_plot_dinas_only, width = 25, height = 20, units = "cm")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import data with main analyses
data <- read.dta("Results/analyses_final.dta")
# Make the plot
firststage_plot_secondid <- data %>%
filter(Polynomials < 5) %>%
filter(FE == "None")  %>%
filter(Outcome == "Turnout")  %>%
mutate(Polynomials = as.factor(Polynomials)) %>%
ggplot(aes(x = Instruments, y = fstat, fill = Polynomials)) +
geom_bar(stat = "identity", position = position_dodge(0.75), color = "gray30") +
theme_bw() +
scale_y_continuous(limits = c(0, 10), breaks = c(0, 2, 4, 6, 8, 10)) +
ylab("F-test") +
scale_fill_brewer(palette = "YlGnBu") +
theme_minimal() +
geom_hline(yintercept = 9, color = "red", linetype = "dashed", size = 1) +
facet_wrap(.~ Predictor)
firststage_plot_secondid
# Save the plot
ggsave("Plots/figd6.png", plot = firststage_plot_secondid, width = 20, height = 15, units = "cm")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import dataset with results
dinas_only <- read.dta13("Results/analyses_final_dinasonly.dta")
# Defining line breaks in the type of outcome
levels(dinas_only$outcome_type) <- gsub("\\n", "\n", levels(dinas_only$outcome_type))
# Fixing levels in outcome and outcome_type variables
dinas_only$Outcome[dinas_only$Outcome == "Summary\\nmeasures (PCA)"] <- "Summary measures (PCA)"
dinas_only$Outcome[dinas_only$Outcome == "Repr underpriviliged\\ngroups (PCA)"] <- "Repr underpriviliged groups (PCA)"
dinas_only$outcome_type[dinas_only$outcome_type == "Summary\\nmeasures"] <- "Summary\nmeasures"
dinas_only$outcome_type[dinas_only$outcome_type == "Descriptive\\nrepr of women"] <- "Descriptive\nrepr of women"
dinas_only$outcome_type[dinas_only$outcome_type == "Repr underpriviliged\\ngroups"] <- "Repr underpriviliged\ngroups"
dinas_only$outcome_type[dinas_only$outcome_type == "Other\\noutcomes"] <- "Other\noutcomes"
# Creating a variable to order the plot by
dinas_only$order_outcome <- 1
dinas_only$order_outcome[dinas_only$outcome_type == "Summary\nmeasures"] <- 0
dinas_only$order_outcome[dinas_only$outcome_type == "Other\noutcomes"] <- 2
# Draw the actual plot
main_plot_dinas_only <- dinas_only %>%
mutate(Outcome = fct_reorder(Outcome, pca)) %>%
mutate(outcome_type = fct_reorder(outcome_type, order_outcome)) %>%
ggplot(aes(Outcome, Effect, color = factor(pca), show.legend = FALSE)) +
geom_hline(aes(yintercept = 0), linetype = 2) +
coord_flip(ylim = c(-1, 1)) +
geom_linerange(aes(ymin = ci_lower, ymax = ci_upper), position = position_dodge(width = 0.75) ) +
geom_point(size = 1, position = position_dodge(width = 0.75) ) +
facet_grid(rows = vars(outcome_type),
scales = "free_y") +
theme_minimal(base_size = 9) +
theme(legend.position = "none",
panel.background = element_rect(fill = NA, color = "black")) +
scale_color_manual(values = c("black", "blue")) +
ylab(" ") +
xlab("")
main_plot_dinas_only
# Save the plot
ggsave("Plots/figd6.png", plot = main_plot_dinas_only, width = 25, height = 20, units = "cm")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import data with main analyses
data <- read.dta("Results/analyses_final.dta")
# Make the plot
firststage_plot_secondid <- data %>%
filter(Polynomials < 5) %>%
filter(FE == "None")  %>%
filter(Outcome == "Turnout")  %>%
mutate(Polynomials = as.factor(Polynomials)) %>%
ggplot(aes(x = Instruments, y = fstat, fill = Polynomials)) +
geom_bar(stat = "identity", position = position_dodge(0.75), color = "gray30") +
theme_bw() +
scale_y_continuous(limits = c(0, 10), breaks = c(0, 2, 4, 6, 8, 10)) +
ylab("F-test") +
scale_fill_brewer(palette = "YlGnBu") +
theme_minimal() +
geom_hline(yintercept = 9, color = "red", linetype = "dashed", size = 1) +
facet_wrap(.~ Predictor)
firststage_plot_secondid
# Save the plot
ggsave("Plots/figd7.png", plot = firststage_plot_secondid, width = 20, height = 15, units = "cm")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import data with main analyses
data <- read.dta("Results/analyses_final.dta")
# Defining line breaks in the type of outcome
levels(data$outcome_type) <- gsub("\\n", "\n", levels(data$outcome_type))
# Fixing levels in outcome and outcome_type variables
table(data$Outcome)
data$Outcome[data$Outcome == "Summary\\nmeasures (PCA)"] <- "Summary measures (PCA)"
data$Outcome[data$Outcome == "Repr underpriviliged\\ngroups (PCA)"] <- "Repr underpriviliged groups (PCA)"
table(data$outcome_type)
data$outcome_type[data$outcome_type == "Summary\\nmeasures"] <- "Summary\nmeasures"
data$outcome_type[data$outcome_type == "Descriptive\\nrepr of women"] <- "Descriptive\nrepr of women"
data$outcome_type[data$outcome_type == "Repr underpriviliged\\ngroups"] <- "Repr underpriviliged\ngroups"
data$outcome_type[data$outcome_type == "Other\\noutcomes"] <- "Other\noutcomes"
# Creating a variable to order the plot by
data$order_outcome <- 1
data$order_outcome[data$outcome_type == "Summary\nmeasures"] <- 0
data$order_outcome[data$outcome_type == "Other\noutcomes"] <- 2
# Make the plot
main_plot2 <- data %>%
filter(Instruments == 1) %>%
filter(Polynomials == 1) %>%
filter(Sample == "Whole") %>%
filter(FE == "None") %>%
filter(Predictor == "Absolute number parl parties") %>%
mutate(Outcome = fct_reorder(Outcome, pca)) %>%
mutate(outcome_type = fct_reorder(outcome_type, order_outcome)) %>%
ggplot(aes(Outcome, Effect, color = factor(pca), show.legend = FALSE)) +
geom_hline(aes(yintercept = 0), linetype = 2) +
coord_flip(ylim = c(-1.5, 1.5)) +
geom_linerange(aes(ymin = ci_lower, ymax = ci_upper), position = position_dodge(width = 0.75) ) +
geom_point(size = 1, position = position_dodge(width = 0.75) ) +
facet_grid(rows = vars(outcome_type),
scales = "free_y") +
theme_minimal(base_size = 9) +
theme(legend.position = "none",
panel.background = element_rect(fill = NA, color = "black")) +
scale_color_manual(values = c("black", "blue")) +
ylab(" ") +
xlab("")
main_plot2
# Save the plot
ggsave("Plots/figd8.png", plot = main_plot2, width = 25, height = 20, units = "cm")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
iv_results <- data %>%
filter(Sample == "Whole") %>%
filter(id == "No. parties just above")  %>%
filter(Predictor == "ENPP")
iv_results$Outcome[iv_results$Outcome == "Summary\nmeasures (PCA)"] <- "Summary\\nmeasures (PCA)"
table(iv_results$Outcome)
table(ols_results$Outcome)
mean(ols_results$Effect[ols_results$Outcome == "Repr underpriviliged\ngroups (PCA)"])
ols_results <- data %>%
filter(Model == "OLS") %>%
# filter(outcome_type != "Summary measures") %>%
#  filter(pca == 0) %>%
filter(Predictor == "ENPP")
compare_coefs <- function(outcome){
# check means
mean_ols <- mean(ols_results$Effect[ols_results$Outcome == outcome])
mean_iv <- mean(iv_results$Effect[iv_results$Outcome == outcome])
message('OLS coefficient:')
print(mean_ols)
# check p-value in OLS
pval_ols <- mean(ols_results$pval[ols_results$Outcome == outcome])
message('OLS p-value:')
print(format(pval_ols, scientific = FALSE))
message('Mean 2SLS coefficient:')
print(mean_iv)
# calculate proportion
proportion_iv_ols <- mean_iv / mean_ols
message('Proportion 2SLS / OLS:')
print(proportion_iv_ols)
}
table(iv_results$Outcome)
compare_coefs("Summary measures (PCA)")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
iv_results <- data %>%
filter(Sample == "Whole") %>%
filter(id == "No. parties just above")  %>%
filter(Predictor == "ENPP")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
data <- read.dta("Results/analyses_final.dta")
iv_results <- data %>%
filter(Sample == "Whole") %>%
filter(id == "No. parties just above")  %>%
filter(Predictor == "ENPP")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import data with results
data <- read.dta("Results/analyses_final.dta")
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import data with results
data <- read.dta("Results/analyses_final.dta")
iv_results <- data %>%
filter(Sample == "Whole") %>%
filter(id == "No. parties just above")  %>%
filter(Predictor == "ENPP")
iv_results$Outcome[iv_results$Outcome == "Summary\nmeasures (PCA)"] <- "Summary\\nmeasures (PCA)"
table(iv_results$Outcome)
table(ols_results$Outcome)
mean(ols_results$Effect[ols_results$Outcome == "Repr underpriviliged\ngroups (PCA)"])
ols_results <- data %>%
filter(Model == "OLS") %>%
# filter(outcome_type != "Summary measures") %>%
#  filter(pca == 0) %>%
filter(Predictor == "ENPP")
compare_coefs <- function(outcome){
# check means
mean_ols <- mean(ols_results$Effect[ols_results$Outcome == outcome])
mean_iv <- mean(iv_results$Effect[iv_results$Outcome == outcome])
message('OLS coefficient:')
print(mean_ols)
# check p-value in OLS
pval_ols <- mean(ols_results$pval[ols_results$Outcome == outcome])
message('OLS p-value:')
print(format(pval_ols, scientific = FALSE))
message('Mean 2SLS coefficient:')
print(mean_iv)
# calculate proportion
proportion_iv_ols <- mean_iv / mean_ols
message('Proportion 2SLS / OLS:')
print(proportion_iv_ols)
}
table(iv_results$Outcome)
compare_coefs("Summary measures (PCA)")
mean(ols_results$Effect[ols_results$Outcome == "Repr underpriviliged\ngroups (PCA)"])
mean(ols_results$Effect[ols_results$Outcome == "Repr underpriviliged\ngroups (PCA)", na.rm = T])
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import data with results
data <- read.dta("Results/analyses_final.dta")
iv_results <- data %>%
filter(Sample == "Whole") %>%
filter(id == "No. parties just above")  %>%
filter(Predictor == "ENPP")
iv_results$Outcome[iv_results$Outcome == "Summary\nmeasures (PCA)"] <- "Summary\\nmeasures (PCA)"
table(iv_results$Outcome)
# Clean up
rm(list = ls())
# Set working directory; please set your own here
setwd("~/Dropbox/Fragmentation/fragmentation_replication_bjps/")
library(tidyverse)
library(foreign)
# Import data with results
data <- read.dta("Results/analyses_final.dta")
iv_results <- data %>%
filter(Sample == "Whole") %>%
filter(id == "No. parties just above")  %>%
filter(Predictor == "ENPP")
iv_results$Outcome[iv_results$Outcome == "Summary\nmeasures (PCA)"] <- "Summary\\nmeasures (PCA)"
table(iv_results$Outcome)
table(ols_results$Outcome)
ols_results <- data %>%
filter(Model == "OLS") %>%
filter(Predictor == "ENPP")
compare_coefs <- function(outcome){
# check means
mean_ols <- mean(ols_results$Effect[ols_results$Outcome == outcome])
mean_iv <- mean(iv_results$Effect[iv_results$Outcome == outcome])
message('OLS coefficient:')
print(mean_ols)
# check p-value in OLS
pval_ols <- mean(ols_results$pval[ols_results$Outcome == outcome])
message('OLS p-value:')
print(format(pval_ols, scientific = FALSE))
message('Mean 2SLS coefficient:')
print(mean_iv)
# calculate proportion
proportion_iv_ols <- mean_iv / mean_ols
message('Proportion 2SLS / OLS:')
print(proportion_iv_ols)
table(iv_results$Outcome)
table(iv_results$Outcome)
table(iv_results$Outcome)
